﻿<Window x:Class="InfFront.InfoViews.WPF.EntrySelectWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:InfFront.InfoViews.WPF"
    xmlns:dg="clr-namespace:Microsoft.Windows.Controls;assembly=WpfToolkit"
    Height="{Binding Path=VisualSettings.EntrySelectWindowHeight, FallbackValue=400, Mode=TwoWay}"
    Width="{Binding Path=VisualSettings.EntrySelectWindowWidth, FallbackValue=400, Mode=TwoWay}" 
    WindowState="{Binding Path=VisualSettings.EntrySelectWindowState, FallbackValue=Normal, Mode=TwoWay}"
    Title="Select" WindowStartupLocation="CenterOwner" ShowInTaskbar="False">
    <Window.Resources>
        <local:IconedObjectToNormal16x16ImageConverter x:Key="getNormal16x16Image"/>
    
        <Style x:Key="defaultButtonStyle" TargetType="{x:Type Button}">
            <Setter Property="Margin" Value="4"/>
            <Setter Property="Padding" Value="4"/>
        </Style>
    
        <Style x:Key="defaultRowStyle" TargetType="{x:Type dg:DataGridRow}">
            <Setter Property="Background" Value="Transparent"/>
        </Style>

    </Window.Resources>

    <Window.Icon>
        <Binding Converter="{StaticResource getNormal16x16Image}" />
    </Window.Icon>
    
    <Grid>
        <Grid.Background>
            <LinearGradientBrush StartPoint="0,0" EndPoint="1,0">
                <GradientStop Offset="0" Color="{Binding Path=VisualSettings.PrimaryBackgroundColor, FallbackValue=Lavender}"/>
                <GradientStop Offset="1" Color="{Binding Path=VisualSettings.SecondaryBackgroundColor, FallbackValue=Azure}"/>
            </LinearGradientBrush>
        </Grid.Background>

        <Grid.RowDefinitions>
            <RowDefinition/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>

        <dg:DataGrid x:Name="dataGrid"                      
                     Grid.Row="0"
                     AutoGenerateColumns="True"                                                            
                     IsSynchronizedWithCurrentItem="True" 
                     RowHeaderWidth="25"
                     ItemContainerStyle="{StaticResource defaultRowStyle}"
                     SelectionChanged="dataGrid_SelectionChanged"
                     MouseDoubleClick="dataGrid_MouseDoubleClick"
                     AutoGeneratedColumns="dataGrid_AutoGeneratedColumns" IsReadOnly="True">
            <dg:DataGrid.Background>
                <LinearGradientBrush StartPoint="0,0" EndPoint="1,1">
                    <GradientStop Offset="0" Color="{Binding Path=VisualSettings.PrimaryGridColor, FallbackValue=White}"/>
                    <GradientStop Offset="1" Color="{Binding Path=VisualSettings.SecondaryGridColor, FallbackValue=Azure}"/>
                </LinearGradientBrush>
            </dg:DataGrid.Background>
        </dg:DataGrid>
        
        <Grid Grid.Row="1">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>
            <UniformGrid Grid.Column="1" Rows="1">
                <Button Name="btnSelect"
                    Style="{StaticResource defaultButtonStyle}"
                    Click="btnSelect_Click">Select</Button>
                <Button Name="btnCancel"
                    Style="{StaticResource defaultButtonStyle}" 
                    Click="btnCancel_Click" IsDefault="True" IsCancel="True">Cancel</Button>
            </UniformGrid>
        </Grid>

    </Grid>
</Window>
